package br.ufg.apkwebservice.ws;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;

import br.ufg.apkwsentidades.Turma;

@Path("/turmas")
public class TurmasManagerWs {

	@GET
	@Produces("application/json")
	public Response getTurmasMatriculadas(@QueryParam("id") Integer id) {

		System.out.println("TURMAS ACESSADA: id:" + id);

		Response response = null;

		TurmasService service = new TurmasService();
		List<Turma> listaDeTurmas = service.buscarTurmasMatriculadas(id);

		if (listaDeTurmas == null || listaDeTurmas.size() == 0) {
			response = Response.status(Response.Status.OK)
					.entity("Nenhuma turma encontrada.").build();
		} else {
			response = Response.status(Response.Status.OK)
					.entity(listaDeTurmas).build();
		}

		return response;
	}
}
